import keyword

import pynput
from pynput import mouse,keyboard


def mouse_on_click_press(x,y,button,pressed):
    if button==mouse.Button.middle:
        return "mouse_middle"
    elif button==mouse.Button.left:
        return "mouse_left"
    elif button==mouse.Button.right:
        return "mouse_right"
    else:
        return "error"


def on_click(x,y,button,pressed):
    # 当鼠标按下时调用
    print(f"Mouse clicked {x}")

def on_press(x,y,button,pressed):
    if button == keyboard.Key.esc:
        print(x,y)

def on_scroll(x,y,scroll,pressed):
    # 当鼠标滚轮滚动时调用
    print(f"Mouse scrolled {scroll}")



def main():
    # 创建并启动监听器
    with mouse.Listener(on_press=on_press,on_click=on_click, on_scroll=on_scroll) as listener:
        listener.join()


main()